buffer:Performance increase for buffer-indexof#7658
buffer:Performance increase for buffer-indexof#7658adrian-nitu-92 wants to merge 1 commit intonodejs:masterfrom adrian-nitu-92:buffer-indexof-perf
Conversation
|
Do you have performance numbers for this? |
lib/buffer.js
Outdated
|
Performance numbers available at, as measured on: |
|
Implemented requested changes :D |
|
What if we just changed the |
|
I looked into that, it gets slightly lower performance(under 1% lower). |
|
Any comments on the (typeof byteOffset === 'string') condition? It feels really awkward :D |
|
|
|
So I gather I should just simplify the patch according to mscdex's comments and resend my patch |
|
@adrian-nitu-92 ... sorry for the delay, updating this PR would be the way to do it. If you're still interested in moving this forward, simply add the new commits here and we'll take a look! :-) |
We are currently analyzing the buffer-indexof performance and noticed that a considerable amount of time is spent in the isNan() function. By simplifying this check we notice a small perf boost. Signed-off-by: Adrian Nitu <adrian.nitu@intel.com>
|
Thank you for the feedback, I simplified my patch |
|
@nodejs/buffer @nodejs/benchmarking @mscdex |
|
@adrian-nitu-92 could you put a comment explaining what you are doing? Its clever, and clever often leads to misunderstanding. A quick comment should alleviate what looks like a bug. The comment below is somewhat misleading, you could also just clean that up. |
|
Is this still something that should happen? |
|
I think adding a comment above the conditional might be a good idea. Either way it LGTM. |
mhdawson
left a comment
There was a problem hiding this comment.
I agree adding a comment explaining what and how the check accomplishes would be useful. Its not obvious otherwise
|
Would be worth it to run this with |
|
@trevnorris I'm not sure it'd be worth it since it needs to be converted anyway? |
|
@mscdex What I mean is that because of: byteOffset = +byteOffset; // Coerce to Number.we can use the more strict |
|
@trevnorris The |
|
@mscdex Hm. Seems the code was updated to use |
|
#12286 seems to duplicate this and include some other things (a benchmark file, a comment explaining why it's doing things this way, and implementing the same change where |
Checklist
make -j4 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
buffer
Description of change
We are currently analyzing the buffer-indexof performance and noticed that a
considerable amount of time is spent in the isNan() function.
By postponing the isNan check we noticed a performance boost.
Signed-off-by: Adrian Nițu adrian.nitu@intel.com